package com.sinosoft.hydra.um.repositories;

import java.util.List;

import cn.com.sinux.spring.repositories.IBaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.sinosoft.hydra.um.domain.permission.SysOrganization;
import org.springframework.transaction.annotation.Transactional;

/**
 * 组织机构(部门)数据层
 * </p>
 * created:2014/12/03
 * 
 * @author oujianlin@sinosoft.co
 */
public interface SysOrganizationRepository extends IBaseRepository<SysOrganization, String> {

	/**
	 * 更具部门ID集合删除SysOrganization对象
	 * @param ids	List<String>
	 * @return
	 */
	@Modifying
    @Transactional
	@Query("update SysOrganization set available = 0 where id in (?1)")
	public int deleteOrganizationByIds(List<String> ids);

    /**
     * 根据parentID查询子部门
     * @param parentid
     * @return
     */
    @Query("from SysOrganization org where org.parentId=?1 and available=1")
    public List<SysOrganization> getChildOrgByParentId(String parentid);
}
